import { createRouter, createWebHistory } from 'vue-router';
const routes = [
  {
    path: '/',
    component: () => import('../views/Home.vue'),
    name: 'home',
    children: [
      {
        path: '/',
        name: 'index',
        component: () => import('../views/Index.vue'),
      }
    ],
  },
  {
    path: '/login',
    component: () => import('../views/Login.vue'),
    name: 'login'
  }
];
const router = createRouter({
  history: createWebHistory(),
  routes, // `routes: routes` 的缩写
})
export default router;

export function setMenu(type: string) {
  if(type == '3') {
    router.addRoute("home", { path: '/user', name: 'user', component: () => import('../views/User.vue') });
    router.addRoute("home", { path: '/teacher', name: 'teacher', component: () => import('../views/Teacher.vue') });
    router.addRoute("home", { path: '/student', name: 'student', component: () => import('../views/Student.vue') });
    router.addRoute("home", { path: '/class', name: 'class', component: () => import('../views/Class.vue') });
  }
}

